package com.xingdata.jjxc.adapter;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.xingdata.jjxc.R;

public class LoveBusAdp extends BaseAdapter {

	// private Activity avt;
	// private List<ComAddressEntity> comEn;

	// public CommAddressAdp(Activity avt, List<ComAddressEntity> comEn) {
	// super();
	// this.avt = avt;
	// this.comEn = comEn;
	// }

	private Context context; // 运行上下文
	private List<Map<String, Object>> listItems; // 联系人信息集合
	private LayoutInflater listContainer;

	public LoveBusAdp(Context context, List<Map<String, Object>> listItems) {
		super();
		this.context = context;
		this.listItems = listItems;
		this.listContainer = LayoutInflater.from(context);
	}

	@Override
	public int getCount() {
		// return comEn == null ? 0 : comEn.size();
		return listItems.size();
	}

	@Override
	public Object getItem(int position) {
		// return carEn.get(position);
		return null;
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

		ViewHolder holder = null;
		if (convertView == null) {
			holder = new ViewHolder();
			// convertView = LayoutInflater.from(avt).inflate(
			// R.layout.item_common_address, null);

			convertView = listContainer.inflate(R.layout.item_love_bus, null);

			holder.item_love_bus_iv = (ImageView) convertView
					.findViewById(R.id.item_love_bus_iv);
			holder.item_love_norm_tv = (TextView) convertView
					.findViewById(R.id.item_love_norm_tv);
			holder.item_love_nommNO_tv = (TextView) convertView
					.findViewById(R.id.item_love_nommNO_tv);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		// ComAddressEntity com = getItem(position);
		// holder.item_common_compyname_tv.setText(com.getAddname());
		// holder.item_common_compyaddress_tv.setText(com.getAddress());

		holder.item_love_norm_tv.setText((String) listItems.get(position).get(
				"lovebusY"));
		holder.item_love_nommNO_tv.setText((String) listItems.get(position)
				.get("lovebusN"));

		return convertView;
	}

	final class ViewHolder {
		public ImageView item_love_bus_iv;
		public TextView item_love_norm_tv, item_love_nommNO_tv;
	}

}
